package toanstt.com.menu;

import toanstt.com.MatchUp.App;
import toanstt.com.MatchUp.ButtonCenter;
import toanstt.com.MatchUp.MainActivity;
import toanstt.com.MatchUp.SCR;
import toanstt.com.MatchUp.Sound2;
import toanstt.com.MatchUp.T;
import toanstt.com.gameplay.G;
import android.graphics.Canvas;
import android.view.MotionEvent;

public class Setting 
{
	ButtonCenter[] buttons;
	int N;
	public Setting()
	{
		int i;
		N=3;
		buttons = new ButtonCenter[N];
		//for(i =0;i<2;i++)
			//buttons[i] = new ButtonCenter(T.TBITMAP_BUTTON_MENU.bitmap[i+9],T.DISPLAY_WIDTH/2,(int)((i+2)*4*T.U2));
		if(T.ISHORIZONTAL)
		{
			
			{
				i=0;
				//buttons[0] = new ButtonCenter(T.TBITMAP_BUTTON_MENU.bitmap[9],T.DISPLAY_WIDTH/2,(int)((i+2)*4*T.U2));
				i=0;
				buttons[0] = new ButtonCenter(T.TBITMAP_BUTTON_MENU.bitmap[11],T.DISPLAY_WIDTH/2,(int)((i+2)*4*T.U2));
				i=1;
				buttons[1] = new ButtonCenter(T.TBITMAP_BUTTON_MENU.bitmap[12],T.DISPLAY_WIDTH/2,(int)((i+2)*4*T.U2));
				
				i=2;
				if(T.ISHORIZONTAL)
					buttons[2] = new ButtonCenter(T.TBITMAP_BUTTON_MENU.bitmap[13],T.DISPLAY_WIDTH/2,(int)((i+2)*4*T.U2));
				//else
					//buttons[2] = new ButtonCenter(T.TBITMAP_BUTTON_MENU.bitmap[21],T.DISPLAY_WIDTH/2,(int)((i+2)*4*T.U2));
				
				//buttons[3] = new ButtonCenter(T.TBITMAP_BUTTON_MENU.bitmap[13],T.DISPLAY_WIDTH/2,(int)(T.DISPLAY_HEIGHT - (int)(2*T.U2)));
			}
		}
		/*else
		{
			i=0;
			buttons[0] = new ButtonCenter(T.TBITMAP_BUTTON_MENU.bitmap[9],T.DISPLAY_WIDTH/2,(int)((i+2)*4*T.U2));
			i=1;
			buttons[1] = new ButtonCenter(T.TBITMAP_BUTTON_MENU.bitmap[11],T.DISPLAY_WIDTH/2,(int)((i+2)*4*T.U2));
			i=2;
			buttons[2] = new ButtonCenter(T.TBITMAP_BUTTON_MENU.bitmap[12],T.DISPLAY_WIDTH/2,(int)((i+2)*4*T.U2));
			
			i=3;
			if(T.ISHORIZONTAL)
				buttons[4] = new ButtonCenter(T.TBITMAP_BUTTON_MENU.bitmap[20],T.DISPLAY_WIDTH/2,(int)((i+2)*4*T.U2));
			else
				buttons[4] = new ButtonCenter(T.TBITMAP_BUTTON_MENU.bitmap[21],T.DISPLAY_WIDTH/2,(int)((i+2)*4*T.U2));
			
			buttons[3] = new ButtonCenter(T.TBITMAP_BUTTON_MENU.bitmap[13],T.DISPLAY_WIDTH/2,(int)(T.DISPLAY_HEIGHT - (int)(5*T.U2)));
		}*/
	}
	int d;
	public void Draw(Canvas canvas)
	{
		if(T.THEME_WHITE == true)
			canvas.drawBitmap(T.TBITMAP_THEME_WHITE.bitmap[0], 0, 0, null);
		else
			canvas.drawBitmap(T.TBITMAP_THEME_BLACK.bitmap[0], 0, 0, null);
		
		for(d =1;d<N;d++)
			buttons[d].Draw2(canvas);
		
		
		buttons[0].Draw2(canvas);
		T.bitmapfont.drawString(canvas, "VOL: " + T.SOUND, T.DISPLAY_WIDTH/2, (int)(3*T.U2), 2);
	}
	int t;
	public void touch(MotionEvent mo)
	{
		if(buttons[2].Kick(mo) == true)
		{
			if(T.SCREEN_TEMP == -1)
			{
				T.SCREEN_TEMP = SCR.MENU;
				T.ALPHA =T.ALPHA_COUNT_MAX;
			}
			//T.SCREEN = SCR.MENU;
		}
		else if(buttons[0].Kick(mo) == true)
		{
			T.sounds.Play(Sound2.BUTTON_CLICK);
			if(T.SOUND <5)
			{
				T.SOUND++;
				T.sounds.Setvolum();
				T.soundtheme.Setvolum();
			}
		}
		else if(buttons[1].Kick(mo) == true)
		{
			T.sounds.Play(Sound2.BUTTON_CLICK);
			if(T.SOUND >0)
			{
				T.SOUND--;
				T.sounds.Setvolum();
				T.soundtheme.Setvolum();
			}
		}
		
		switch(App.action)
		{
			case MotionEvent.ACTION_DOWN:
				
			break;
			
			case MotionEvent.ACTION_UP:
				for(d =0;d<N;d++)
					buttons[d].anpla = 255;
			break;
			
			case MotionEvent.ACTION_MOVE:
			break;

		}
	}
}
